package com.xuecheng.content.feignclient;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author: Hes
 * @description 熔断后降级处理的类
 * @date: 2023/6/25 11:00
 */
@Slf4j
@Component
public class MediaServiceClientFactory implements FallbackFactory<MediaServiceClient> {
    @Override
    public MediaServiceClient create(Throwable throwable) {
        return new MediaServiceClient() {
            @Override
            public String uploadFile(MultipartFile multipartFile, String objectName) {
                log.debug("远程调用媒资服务已熔断,objectName:{}", objectName, throwable.getMessage());
                return null;
            }
        };
    }
}
